package com.itheima.model.vo;

import com.itheima.model.domain.UserInfo;
import com.itheima.model.mongo.Video;
import lombok.Data;
import org.bson.types.ObjectId;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;

/**
 * @author zhangpei
 * @ClassName VideosDto
 * @date 2022/6/24/21:12
 */
@Data
public class VideosDto  {

    private ObjectId id;
    private Long createDate;
    private String videoUrl;
    private String picUrl;

    private Integer reportCount = 0;
    private Integer likeCount;
    private Integer commentCount;

    private Integer userId;

    private String state;
    private Integer forwardingCount = 0;
    private String nickname;
    private List<Vo> totals;

    public static VideosDto init(UserInfo userInfo, Integer userId, Video video) {
        VideosDto videosDto = new VideosDto();
        BeanUtils.copyProperties(video, videosDto,"userId","created");
        videosDto.setCreateDate(video.getCreated());
        videosDto.setLikeCount(video.getLikeCount());
        videosDto.setCommentCount(video.getCommentCount());
        videosDto.setNickname(userInfo.getNickname());
        videosDto.setUserId(userId);
        return videosDto;
    }
}
